var inner = document.getElementById('inner');
var oliList = document.getElementsByTagName('li');
var banner = document.getElementById('banner');
var aRight = document.getElementById('right');
var aLeft = document.getElementById('left');
var indexJsonData = json.jsonData;
var i = 1;
var k = 1;
console.log(json.jsonData);
//轮播动画定时器
var timer = window.setInterval(function(){
    if(i==indexJsonData.length/2 + 1){
        inner.style.left = '0px';
        i = 1;

    }
        tween.moveAllDeraction(inner,{
            left:-1000*i++
        
        },500);
        
        
        
        var curLeft = window.getComputedStyle(inner,null).left;
    
    },1000);
//li选中定时器active
var oliTimer = window.setInterval(function(){
   if(k==indexJsonData.length/2){
       k=0;
   }
    for(var j = 0 ; j < oliList.length ; j++){
        var curEle = oliList[j];
        if(j==k){
            curEle.className = "active";
        }else{
            curEle.className = "";
        }
    }
    k++;
},1000);
//解决浏览器切换，定时器发生紊乱的问题
document.addEventListener("visibilitychange", function() {

    if(document.hidden === true) {
        // 页面被挂起
        window.clearInterval(timer);
        window.clearInterval(oliTimer);
    } else {
        // 页面由挂起被激活
        timer = window.setInterval(function(){
            if(i==indexJsonData.length/2 + 1){
                inner.style.left = '0px';
                i = 1;
        
            }
                tween.moveAllDeraction(inner,{
                    left:-1000*i++
                
                },500);
                
                
                
                var curLeft = window.getComputedStyle(inner,null).left;
            
            },1000);

            oliTimer = window.setInterval(function(){
                if(k==indexJsonData.length/2){
                    k=0;
                }
                 for(var j = 0 ; j < oliList.length ; j++){
                     var curEle = oliList[j];
                     if(j==k){
                         curEle.className = "active";
                     }else{
                         curEle.className = "";
                     }
                 }
                 k++;
             },1000);

    }
    });

liFunctions.bannerMouseMove();

json.getJson();
json.setJson();
for(var index = 0;index<indexJsonData.length/2;index++){
    liFunctions.oliClick(oliList[index]);
}

aRight.onclick = aFunctions.toRight;
aLeft.onclick = aFunctions.toLeft;


